import java.util.ArrayDeque;
import java.util.LinkedList;
import java.util.Stack;

public class StackToQueue {
    class MyQueue {
        public ArrayDeque<Integer> stack1;
        public ArrayDeque<Integer> stack2;

        public MyQueue() {
            stack1=new ArrayDeque<>();
            stack2=new ArrayDeque<>();
        }

        public void push(int x) {
            stack1.push(x);
        }

        public int pop() {
            if(empty()){
                return -1;
            }
            if(!stack1.isEmpty()){
                int size=stack1.size();
                for(int i=0;i<size;i++){
                    stack2.push(stack1.pop());
                }
            }
            return stack2.pop();


        }

        public int peek() {
            if(empty()){
                return -1;
            }
            if(!stack1.isEmpty()){
                int size=stack1.size();
                for(int i=0;i<size;i++){
                    stack2.push(stack1.pop());
                }
            }
            return stack2.peek();


        }

        public boolean empty() {
            return stack1.isEmpty()&&stack2.isEmpty();
        }
    }
    }

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue obj = new MyQueue();
 * obj.push(x);
 * int param_2 = obj.pop();
 * int param_3 = obj.peek();
 * boolean param_4 = obj.empty();
 */

